<?php
// ====================================================
// filename:wl101_delete.php
// summary: 用户管理画面_添加用户
// ====================================================
require_once ("../init.php");
php_handle();

function php_handle()
{
    $uid = $_SESSION['wl_uid'];
    $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : "";
    $user_name = isset($_POST['user_name']) ? $_POST['user_name'] : "";
    $user_tel = isset($_POST['user_tel']) ? $_POST['user_tel'] : "";
    $user_remark = isset($_POST['user_remark']) ? $_POST['user_remark'] : "";
    
    if (empty($user_name)) {
        echo json_encode(array(
            'success' => false,
            'msg' => "用户名不能为空，请确认！"
        ));
        return;
    }
    
    if (empty($user_tel)) {
        echo json_encode(array(
            'success' => false,
            'msg' => "手机号码不能为空，请确认！"
        ));
        return;
    }
    
    $wlu02 = new wlu02tbx();
    $u02_2res = $wlu02->sel_wlu02tbx_by_user_tel($user_tel, $user_id);
    if (count($u02_2res) > 0) {
        echo json_encode(array(
            'success' => false,
            'msg' => "输入的手机号码已存在，请确认！"
        ));
        return;
    }
    
    $u02upd = array();
    $u02upd["user_id"] = $user_id;
    $u02upd["user_tel"] = $user_tel;
    $u02upd["user_name"] = $user_name;
    $u02upd["user_remark"] = $user_remark;
    
    $u02rec = $wlu02->update($uid, $u02upd);
    if ($u02rec == 0) {
        echo json_encode(array(
            'success' => false,
            'msg' => "用户修改失败！"
        ));
        return;
    }
    
    echo json_encode(array(
        'success' => true,
        'data' => $user_id
    ));
    return;
}

?>
